package com.foreknow.demo5;

/**
 * 方法与构造器的重载
 */
public class OverloadDemo {
    private int age;
    private String name;

    public OverloadDemo() {

    }

    public OverloadDemo(int age,String name) {
        this.age = age;
        this.name = name;
    }

    public int add(int a,int b) {
        return a + b;
    }

    public int add(int a,int b,int c){
        return a + b + c;
    }

    public static void main(String[] args) {
        OverloadDemo over = new OverloadDemo(20,"tom");
        int sum = over.add(1,2,3);
        System.out.println(sum);

        int sum1 = over.add(3,4);
        System.out.println(sum1);

    }
}
